package com.yq.ylmall.api.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.yq.ylmall.client.product.ProductFeignClient;
import com.yq.ylmall.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "首页数据")
@RequiredArgsConstructor
@RequestMapping("/api/index")
public class IndexController {

    private final ProductFeignClient productFeignClient;

    @ApiOperation(value = "获取分类")
    @GetMapping("/category")
    @SentinelResource(value = "indexCategory")
    public Result<String> getIndexCategory() {
        return Result.ok(productFeignClient.indexCategory());
    }

    @ApiOperation(value = "获取Banner")
    @GetMapping("/banner")
    @SentinelResource(value = "indexBanner")
    public Result<String> getIndexBanner() {
        return Result.ok(productFeignClient.indexBanner());
    }

}
